package com.zmn.oms.third.koubei.dto;

import com.alibaba.fastjson.annotation.JSONField;
import com.taobao.api.TaobaoResponse;
import com.zmn.oms.third.koubei.KoubeiConsts;
import lombok.Data;

import java.io.Serializable;

/**
 * 口碑渠道请求失败应答数据定义
 *
 * @author xiewenbing
 * @date 2021/08/16
 */
@Data
public class KoubeiFailedResponse implements Serializable {

    /**
     * 是否成功
     */
    @JSONField(name = "biz_success")
    boolean bizSuccess;

    /**
     * 错误码
     */
    @JSONField(name = "error_code")
    String errorCode;

    /**
     * 错误消息
     */
    @JSONField(name = "error_message")
    String errorMessage;

    /**
     * 构造函数
     * @param bizSuccess
     */
    public KoubeiFailedResponse(boolean bizSuccess) {
        this.errorCode = "";
        this.errorMessage = "";
        this.bizSuccess = bizSuccess;
    }

    /**
     * 构造函数
     * @param code
     * @param msg
     */
    public KoubeiFailedResponse(String code, String msg) {
        this.errorCode = code;
        this.errorMessage = msg;
        this.bizSuccess = false;
    }

    /**
     * 处理失败
     * @param msg
     * @return
     */
    public static KoubeiFailedResponse handleFailed(String msg) {
        return new KoubeiFailedResponse(KoubeiConsts.HANDLE_FAILED_CODE, msg);
    }

    /**
     * 验签失败
     * @param
     * @return
     */
    public static KoubeiFailedResponse verifySignFailed() {
        return new KoubeiFailedResponse(KoubeiConsts.VERIFY_SIGN_FAILED_CODE, KoubeiConsts.VERIFY_SIGN_FAILED_MSG);
    }
}
